package yang.learn.service.impl;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yang.learn.dao.ContactsDao;
import yang.learn.entity.Contacts;
import yang.learn.entity.User;
import yang.learn.service.ContactsService;

import java.util.List;

@Service
public class ContactsServiceImpl implements ContactsService {

    @Autowired(required = false)
    private ContactsDao contactsDao;

    @Override
    public void add(Contacts contacts) {
        contactsDao.add(contacts);
    }

    @Override
    public void del(Contacts contacts) {
        contactsDao.del(contacts);
    }

    @Override
    public void change(Contacts contacts) {
        contactsDao.change(contacts);
    }

    public List<Contacts> queryAll(User user){
        List<Contacts> list = contactsDao.queryAll(user.getUser_id());
        return list;
    }

    @Override
    public Contacts query(Contacts contacts) {
        contacts = contactsDao.query(contacts.getUser_id());
        return contacts;
    }

}
